/**
 * ======================================================
 * GLOCAL - Event-Based Retrieval of Networked Media
 * EU FP7 funded project to investigate methods to
 * generate, manage, share and retrieve multimedia
 * data in the networked environment, making use of
 * the conception of 'event' and 'context' in both
 * local (person) and global (community) scales.
 * http://www.glocal-project.eu
 *
 * Copyright (c) 2009 - 2012 L3S Forschungszentrum
 * http://www.l3s.de/web/page54g.do?changedAlts=
 * alt4g&sp=page18g&alt4g=page55g&kcond15g.att178a=1770
 * 
 * ======================================================
 * 
 * This module contains implementation source codes for
 * providing access services to the repository of users
 * and events which are located in L3S. It is part of 
 * the deliverables D3.2 in WP3. More details can be 
 * found at:
 * http://www.glocal-project.eu/news/software-modules-wp3
 *
 * 
 * The module is in alpha version, and subject to 
 * minor or partial changes during the integration phase (WP4),
 * upon requests and requirements among GLOCAL partners.
 *
 */
package de.l3s.forgetit.services;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

import com.sun.grizzly.http.SelectorThread;
import com.sun.jersey.api.container.grizzly.GrizzlyWebContainerFactory;

/**
 * @author tuan
 * 
 */
public class GrizzlyService { 
	
	public static void main(String[] args) {
		Map<String, String> initParams = new HashMap<String, String>();
		
		initParams.put("com.sun.jersey.config.property.packages", "de.l3s.forgetit.services.resources;org.codehaus.jackson.jaxrs");
		initParams.put("com.sun.jersey.api.json.POJOMappingFeature", "true");
		initParams.put("configs.config.server-config.transaction-service.automatic-recovery", "true");
	
		 try {
			// startLocalService(initParams);
			startRemoteService(initParams);
		} catch (IOException e) {
			e.printStackTrace();
		}
		
		System.out.println("Starting grizzly...");
	} 
	 
	private static void startRemoteService(Map<String, String> initParams) throws IOException {
		SelectorThread threadSelector = GrizzlyWebContainerFactory.create(Config.URL_BASE, initParams);		
		System.out.println("Server started on " + Config.URL_BASE); 
	}
	
	private static void startLocalService(Map<String, String> initParams) throws IOException {
		SelectorThread threadSelector = GrizzlyWebContainerFactory.create(Config.URL_TEST, initParams);
		System.out.println("Server started on http://localhost:9998/");
	}
}
